package com.example.danangtravel;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.sax.StartElementListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class TbShoppingAdapter extends BaseAdapter {
	public Context context;
	public List<Tbshopping> list;
	public OnClickListener listenner;

	// public ContactDataSource data ;
	public TbShoppingAdapter(Context context, List<Tbshopping> list) {
		this.context = context;
		this.list = list;
	}

	public void setButtonListenner(OnClickListener listenner) {
		this.listenner = listenner;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return (Tbshopping) list.get(arg0);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		// data = new ContactDataSource(context.getApplicationContext());
		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.row_tbshopping, null);
		}
		TextView name = (TextView) convertView.findViewById(R.id.list_name);
		name.setText(list.get(position).getName());
		TextView add = (TextView) convertView.findViewById(R.id.list_add);
		add.setText(list.get(position).getAdress());
		convertView.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Toast.makeText(v.getContext(), "ok", 1000).show();
			}
		});
		return convertView;

	}
}
